<template>
  <div class="multi-media">
    <div class="video-grid" v-if="cameraAllInfo.length > 0">
      <div
        v-for="(stream, index) in cameraAllInfo"
        :key="index"
        class="video-item"
        @dblclick="handleDoubleClick(stream)"
      >
        <div class="video-item-title">
          {{ stream.channelName }}
        </div>
        <div class="video-item-container">
          <EasyPlayerPro
            class="video-block"
            :videoObject="stream"
          ></EasyPlayerPro>
        </div>
      </div>
    </div>
    <div class="no-video" v-else>请前往登录配置视频通道！</div>
  </div>
</template>

<script>
// import VideoBlock from './VideoBlock.vue';
import EasyPlayerPro from '@/components/EasyPlayerPro/index.vue';
// <video-block class="video-block" :videoObject="stream"></video-block>
// import { VIDEO_STREAMS } from '../js/index'
export default {
  name: 'MultiMedia',
  components: { EasyPlayerPro },
  props: {
    cameraAllInfo: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    /**
     * 处理双击事件
     */
    handleDoubleClick(stream) {
      // 处理双击事件，例如播放暂停等操作
      this.$emit('double-click', stream);
    },
  },
};
</script>

<style scoped>
.multi-media {
  width: 100%;
  height: calc(100% - 52px);
  padding: 0 10px 10px 10px;
  background-color: #f5f5f5;
  display: flex;
  justify-content: center;
  box-sizing: border-box;
  /* align-items: center; */
}
.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  row-gap: 10px;
  column-gap: 10px;
  width: 100%;
  max-height: 100%;
  box-sizing: border-box;
}

.video-item {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  /* max-height: 340px; */
  /* border: 1px solid #e7ececc9; */
  box-sizing: border-box;
  justify-content: center;
  align-items: center;
  overflow: hidden; /* 防止内容溢出 */
}
.video-item-title {
  width: 100%;
  height: 30px;
  line-height: 30px;
  text-align: center;
  font-size: 16px;
  color: #333;
  overflow: hidden;
}
.video-item-container {
  padding-bottom: 56.25%;
  width: 100%;
  position: relative;
}

.video-item-container .video-block {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  object-fit: cover; /* 视频填充方式 */
}

.no-video {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 54px;
}
</style>
